#include "stdafx.h"
#include "tray_event_listener.h"
#include "Tray/Tray.h"
#include "Window/ConfigWnd.h"

CxTrayEventListener::CxTrayEventListener()
    : m_pConfig(NULL)
{

}

CxTrayEventListener::~CxTrayEventListener()
{

}

BOOL CxTrayEventListener::OnEvent(UINT nId, UINT nEventId, WPARAM wParam, LPARAM lParam)
{
    switch (nEventId)
    {
    case CxTray::xTray_Event_Config:
        {
            if (!m_pConfig)
            {
                m_pConfig = new (std::nothrow) CxConfigWnd;
            }

            if (m_pConfig)
            {
                m_pConfig->Create();
                m_pConfig->CenterWindow();
                m_pConfig->ShowWindow(SW_SHOW);
            }
        }
        break;
    case CxTray::xTray_Event_Exit:
        {
            ::PostQuitMessage(0);
        }
        break;
    default:
        break;
    }

    return TRUE;
}